package WangLuoSheBei;

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;

public class InetAddressTest {
    public static void main(String[] args) throws IOException {
        //获取本机IP地址对象的
        InetAddress i1 = InetAddress.getLocalHost();
        System.out.println(i1.getHostName());
        System.out.println(i1.getHostAddress());
        //获取指定IP或者域名的IP地址对象
        InetAddress ip2 = InetAddress.getByName("www.baidu.com");
        System.out.println(ip2.getHostName());
        System.out.println(ip2.getHostAddress());

        System.out.println(ip2.isReachable(6000));

    }
}
